package com.wd.mainmodel.fragment;

import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;

import com.wd.base.config.Constance;
import com.wd.base.router.ARouter;
import com.wd.base.ui.BaseFragment;
import com.wd.base.util.ViewUtils;
import com.wd.mainmodel.R;
import com.wd.mainmodel.view.ContentView;
import com.wd.mainmodel.view.TopView;

/**
 * NA<BR>
 *
 * @author w4425
 * @version [V1.0.0, 2021/4/21]
 * @since V1.0.0
 */
public class MainFragment extends BaseFragment {
    private FrameLayout topLayout;
    private FrameLayout contentLayout;
    private Button btnDemoA;
    private Button btnTabLinkage;
    private Button btnJetPack;

    /**
     * 获取MainFragment实例对象
     *
     * @return MainFragment
     */
    public static MainFragment newInstance() {
        return new MainFragment();
    }

    @Override
    protected String getLogTag() {
        return "MainFragment";
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_main_new;
    }

    @Override
    protected void initView(View view) {
        topLayout = view.findViewById(R.id.fl_top);
        contentLayout = view.findViewById(R.id.fl_content);
        btnDemoA = ViewUtils.findViewById(view, R.id.btn_demo_a);
        btnTabLinkage = ViewUtils.findViewById(view, R.id.btn_tab_linkage);
        btnJetPack = ViewUtils.findViewById(view, R.id.btn_tab_jetpack);
        setListener();
        topLayout.addView(new TopView(getActivity()));
        contentLayout.addView(new ContentView(getActivity()));
    }

    private void setListener() {
        btnDemoA.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance()
                        .build(Constance.MODULE_URL_DEMO_A)
                        .navigation(getActivity(), null);
            }
        });
        btnTabLinkage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance()
                        .build(Constance.MODULE_URL_DEMO_TAB_LINKAGE)
                        .navigation(getActivity(), null);
            }
        });
        btnJetPack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance()
                        .build(Constance.MODULE_URL_TAB_JETPACK)
                        .navigation(getActivity(), null);
            }
        });
    }

    @Override
    protected void initViewModel() {
    }

    @Override
    protected void loadData() {
    }

}